package com.mindskip.xzs.controller.admin;



import com.mindskip.xzs.base.*;

import com.mindskip.xzs.domain.TWjTm;

import com.mindskip.xzs.service.TWjTmService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController("AdminWJEducationController")
@RequestMapping(value = "/api/admin/wjEducation")
public class WJEducationController extends BaseApiController {

    @Autowired
    private  TWjTmService tWjTmService;

    //分页查询
    @RequestMapping(value = "/findPage", method = RequestMethod.POST)
    public PageResult findPage(@RequestBody QueryPageBean queryPageBean) {
        return tWjTmService.findByCondition(queryPageBean);
    }

    //添加
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public Result add(@RequestBody TWjTm tWjTm) {
        try{
            tWjTmService.insertTWjTm(tWjTm);
            return new Result(true,MessageConstant.ADD_WJ_SUCCESS);
        }catch (Exception e){
            e.printStackTrace();
            return new Result(false, MessageConstant.ADD_WJ_FAIL);
        }
    }

    //删除
    @RequestMapping(value = "/delete/{id}", method = RequestMethod.POST)
    public Result delete(@PathVariable Integer id) {

        try{
            tWjTmService.deleteTWjTmById(id);
            return new Result(true,MessageConstant.DELETE_WJ_SUCCESS);
        }catch (Exception e){
            e.printStackTrace();
            return new Result(false, MessageConstant.DELETE_WJ_FAIL);
        }
    }

    //编辑
    @RequestMapping(value = "/edit", method = RequestMethod.POST)
    public Result edit(@RequestBody TWjTm tWjTm) {

        try {
            tWjTmService.updateTWjTm(tWjTm);
            return new Result(true, MessageConstant.EDIT_WJ_SUCCESS);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, MessageConstant.EDIT_WJ_FAIL);
        }
    }

}
